package org.thingsboard.server.dao.sql.custom;


import com.google.common.util.concurrent.ListenableFuture;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Component;
import org.thingsboard.server.common.data.custom.DeviceGroup;
import org.thingsboard.server.common.data.id.TenantId;
import org.thingsboard.server.dao.DaoUtil;
import org.thingsboard.server.dao.custom.DeviceGroupDao;
import org.thingsboard.server.dao.model.sql.custom.DeviceGroupEntity;
import org.thingsboard.server.dao.sql.JpaAbstractDao;

import javax.annotation.Resource;
import java.util.Collection;
import java.util.List;
import java.util.UUID;


@Component
@Slf4j
public class JpaDeviceGroupDao extends JpaAbstractDao<DeviceGroupEntity, DeviceGroup> implements DeviceGroupDao {

    @Resource
    private DeviceGroupRepository deviceGroupRepository;


    @Override
    protected Class<DeviceGroupEntity> getEntityClass() {
        return DeviceGroupEntity.class;
    }

    @Override
    protected CrudRepository<DeviceGroupEntity, UUID> getCrudRepository() {
        return deviceGroupRepository;
    }

    @Override
    public List<DeviceGroup> find(TenantId tenantId) {
        return null;
    }

    @Override
    public DeviceGroup findById(TenantId tenantId, UUID id) {
        return deviceGroupRepository.findById(id).get().toData();
    }

    @Override
    public ListenableFuture<DeviceGroup> findByIdAsync(TenantId tenantId, UUID id) {
        log.debug("Get entity by key async {}", id);
        return service.submit(() -> DaoUtil.getData(getCrudRepository().findById(id)));
    }

    @Override
    public boolean existsById(TenantId tenantId, UUID id) {
        return false;
    }

    @Override
    public ListenableFuture<Boolean> existsByIdAsync(TenantId tenantId, UUID id) {
        return null;
    }

    @Override
    public DeviceGroup save(TenantId tenantId, DeviceGroup deviceGroup) {
        return null;
    }

    @Override
    public boolean removeById(TenantId tenantId, UUID id) {
        return false;
    }

    @Override
    public void removeAllByIds(Collection<UUID> ids) {

    }

    @Override
    public Long countByTenantId(TenantId tenantId) {
        return null;
    }
}
